﻿using Anke.SHManage.MSSQLDAL.TJDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class TJ_BSDJModeWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();

            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();
            //this.HiddenForType.Value = "";
        }
        private void InitPage()
        {
            this.Years.Value = DateTime.Now.Year.ToString();
            
            BindReportDataSource();
        }

        protected void BindReportDataSource()
        {
       
            string year = (this.Years.Value).ToString();
            string centerID = (this.Center.Text).ToString();
            string stationID = (this.Station.Text).ToString();
            string workID = (this.WorkID.Text).ToString();
            string name = (this.Name.Text).ToString();
            string type = (this.Type.Value).ToString();
            string start1 = (this.Years.Value).ToString();
            string type1 = (this.Type.Value).ToString();
            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/TJ_BSDJ.rdlc");
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("StartTime", start1);
            Microsoft.Reporting.WebForms.ReportParameter ty = new Microsoft.Reporting.WebForms.ReportParameter("Type", type1);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st,ty});
            TJDAL dal = new TJDAL();
            DataTable dt = dal.Get_TJ_BSDJ(year, centerID, stationID, type ,workID, name);
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_BSDJ", dt));

            this.ReportViewer1.LocalReport.Refresh();
        }
    }
}